<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>

<form:form commandName="model" cssClass="validate"
	id="ciRelationUsePropetyForm"
	action="configuration/ciRelationUsePropety/save">
	<form:hidden path="id" />
	<form:hidden path="relationTypeId" />
	<div class="header" style="min-height:20px;height: auto;">
		<h2>
			&nbsp;&nbsp;${relationType.name }，关联属性设置<span><font
				color="red">（* 为必填项）</font> </span>
		</h2>
	</div>
	<table class="form-table">
		<tbody>
			<tr>
				<td class="td1">主关联资产A的属性：</td>
				<td class="td2"><form:select path="fromPropertyId"
						data-width="300px" items="${fromProperties }" itemLabel="name"
						itemValue="id" cssClass="required" />
				</td>
			</tr>
			<tr>
				<td class="td1">被关联资产B的属性：</td>
				<td class="td2"><form:select path="toPropertyId"
						data-width="300px" items="${toProperties }" itemLabel="name"
						itemValue="id" cssClass="required" />
				</td>
			</tr>

			<tr>
				<td class="td1">是否关联标识：</td>
				<td class="td2"><form:radiobutton value="1" cssClass="required"
						path="useForRelation" label="是" /> <form:radiobutton value="0"
						cssClass="required" path="useForRelation" label="否" />
					<p style="color:red">
						（如果是关联标识，表示此属性映射作为建立关联关系的其中一个条件）</span>
			</tr>

			<tr>
				<td class="td1">关联值写入方式：</td>
				<td class="td2"><form:radiobutton path="usePropertyType"
						value="1" cssClass="required" label="A属性写入B" /><br> <form:radiobutton
						path="usePropertyType" value="0" label="B属性回写A(一对多用,号隔开)"
						cssClass="required" /><br> <form:radiobutton
						path="usePropertyType" value="-1" label="不写值" cssClass="required" />
					<p style="color:red">
						（如果是关联标识，只支持A属性写入B或者不写值）</span>
				</td>
			</tr>

			<tr>
				<td class="td1">排列顺序：</td>
				<td class="td2"><form:input path="orderNum" class="number" />
				</td>
			</tr>

		</tbody>
	</table>
</form:form>

<script type="text/javascript">
	function setUsePropertyType() {

		var useForRelationVal = $("input[name='useForRelation']:checked").val();
		if (useForRelationVal) {
			var usePropertyTypeVal = $("input[name='usePropertyType']:checked").val();

			if (usePropertyTypeVal == "0") {
				var usePropertyTypeEle = $("input[name='usePropertyType']");
				usePropertyTypeEle.prop("checked", false);
				usePropertyTypeEle.eq("0").prop("checked", "checked");
			}
		}
	}

	$(document).ready(function() {
		//setUsePropertyType();

		$("input[name='useForRelation']").change(function() {
			setUsePropertyType();
		});

		$("input[name='usePropertyType']").change(function() {
			var val = $(this).val();

			var useForRelationVal = $("input[name='useForRelation']:checked").val();
			if (useForRelationVal == "1" && val == "0") {
				var usePropertyTypeEle = $("input[name='usePropertyType']");

				usePropertyTypeEle.prop("checked", false);
				usePropertyTypeEle.eq("0").prop("checked", "checked");

			}
		});
	});
</script>

<isperp:buttonList>
	<button class="submit nui-mainbtn" onclick="isperp.submitForm();">保存</button>
</isperp:buttonList>


